package com.tengju.user.domain.model.user;

import lombok.AllArgsConstructor;

/**
 * @author wuziyang
 */
@AllArgsConstructor
public enum Sex {

    /**
     * 男
     */
    UNKNOW(0,"未知"),
    /**
     * 男
     */
    MALE(1,"男"),
    /**
     * 女
     */
    FEMALE(2,"女");

    private Integer val;
    private String desc;

    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public static Sex fromVal(Integer val) {
        for (Sex type : values()) {
            if (type.val.equals(val)) {
                return type;
            }
        }
        return null;
    }

    public static Sex fromName(String name) {
        for (Sex type : values()) {
            if (type.name().equals(name)) {
                return type;
            }
        }
        return null;
    }
}
